﻿var modalDeleteReport;

$().ready(function () {
    modalDeleteReport = new ModalDeleteReport();
    modalDeleteReport.init();
});

function ModalDeleteReport() {
    var _this = this;
    var ajaxUrl = "/Developer/DeleteReport";
    this.init = function () {

        $(".delete").click(function () {
            var item = $(this).siblings(".report-id");
            OpenConfirm("Are you sure you want to delete the report?",
                    function () {
                        _this.execute(item.val());
                    });
        });
    }

    this.execute = function (ID) {
        var dataAjax = {
            reportId: ID
        }

        $.ajax(
        {
            type: "POST",
            url: ajaxUrl,
            data: dataAjax,
            success: function (data) {
                if (data.result == true) {
                    window.location.replace("/Developer/MyReports");
                }
                else {
                }
            },
            error: function () {
                alert("Ошибка");
            }
        });
    }
}